using System;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
using SouthernLand.Common;

namespace SouthernLand.WebMaster.Advertise
{
    public partial class Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btDelete_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow row in GridViewItem.Rows)
            {
                bool isChecked = ((CheckBox) row.FindControl("chkSelect")).Checked;
                if (isChecked)
                {
                    int LogoID = Convert.ToInt32(((CheckBox) row.FindControl("chkSelect")).ToolTip.Trim());
                    Common.BOL.Advertise.Advertise.Delete(LogoID);
                }
            }

            GridViewItem.DataBind();
        }

        protected string GetAdvertise(string FileName, int Width, int Height)
        {
            Width = 130;
            Height = 130;

            if (Path.GetExtension(FileName).ToLower() == ".swf")
                return "<script>WriteObject('" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' ," + Width +
                       "," + Height + ");</script>";
            else
            {
                Height = -1;

                if (Width > 0 && Height > 0)
                    return "<img src='" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' border=0 width=" +
                           Width + " Height=" + Height + "   />";
                else if (Width > 0)
                    return "<img src='" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' border=0 width=" +
                           Width + " />";
                else if (Height > 0)
                    return "<img src='" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' border=0 Height=" +
                           Height + " />";
                else
                    return "<img src='" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' border=0 />";
            }
        }

        protected void btSearch_Click(object sender, EventArgs e)
        {
            GridViewItem.DataSourceID = "SearchDataSource";
            GridViewItem.DataBind();
        }
    }
}